<?php
/**
 * @Author:      zk
 * @DateTime:    18-7-25 下午4:05
 * @Description: 审批模型审批条件表相关
 */

class OAApproverRule extends Eloquent
{
    protected $table = 'oa_approver_rule';
    
    /**
     * 条件运算符数组 [1:=;2:!=;3:<;4:>;5:<=;6:>=;7:in;]
     * @var type 
     */
    public static $operator_arr = [
        1 => '=',
        2 => '!=',
        3 => '<',
        4 => '>',
        5 => '<=',
        6 => '=>',
        7 => 'in',
    ];
    
    /**
     * @Author:      zk
     * @DateTime:    18-7-27 下午1:57
     * @Description: 根据审批模型审批条件分组id获取相应的条件
     * @param int $rule_group_id 审批条件组id
     * @return array
     */
    public static function getRuleByRuleGroupId($rule_group_id){
        $select_arr = [
            'approval_model_id', 'rule_group_id', 'key_name', 'operator', 'key_value', 'sort', 'relation',
        ];
        $list = OAApproverRule::where('rule_group_id', $rule_group_id)
                ->where('status', 1)
                ->select($select_arr)
                ->orderBy('sort')
                ->get()
                ->toArray();
        return $list;
    }
    
}
